nixOS on a Pi from the SSD
My recent interest in nixOS made me remember having a Raspberry Pi 4 lying around. Hearing that nixOS might be storage intensive and having had many bad experiences with SD cards and having watched the excellent talk on SD cards here, made me reconsider using the Pi.
But then I remembered that others have used addon boards to support all kinds of storage. So I decided to go the M.2 SATA route with a probably way too expensive board from Amazon. I choose the GeeekPi Board X862 V2.0 NGFF.
I started by downloading one of the latest SD Card images for the Pi from hydra.
First you have to decompress the image, e.g., via unzstd nixos-image-sd-card-25.11pre836203.dc9637876d0d-aarch64-linux.img.zst. Then used a tool of your choice to transfer the image to a SD card.
Booting from the SD card was easy. I followed every step from the official documentation(s) and also added https://search.nixos.org/packages?channel=25.05&show=linuxKernel.kernels.linux_rpi4&from=0&size=50&sort=relevance&type=packages&query=linux_rpi to my boot.kernelPackages among other things.
The gist is, this will not work. I am new to nixOS so I might miss something very obvious, but I could not easily find out how to get it to work. And by get it to work I mean boot from the SSD when the SD card is not present, which is my desired end state.
So feel free to enlighten me on how to fix this issue, because the way I fixed it was the following:
I addressed the glaringly obvious gaping hole: THERE IS LITERALLY NO FIRMWARE NOR BOOTLOADER .bin on /boot nor the .dtb files which should have come from the linux_rpi4 package I set the boot.kernelPackages to
I do not know why those things are not where they should be, because I explicitly tried running nixos-rebuild boot --install-bootloader and similar commands and they did not add the required files. The fix was to mount the boot partition of the SD card and copy over the missing files to /boot.
Which files those are, some are defined here: https://github.com/NixOS/nixpkgs/blob/e07409d81c70d72197c6b8355607d8ae891a8862/nixos/modules/installer/sd-card/sd-image-aarch64.nix#L90-L96
So if I can find the nerve, I will try to learn how to use the sd-image-aarch64.nix to integrate it into my (hardware?) configuration.
Although this was a pain in the ass, I honestly enjoyed it, because the way nix works gave me confidence of not really breaking things and being able to always boot from the SD card and basically nixos-install things again was really neat.